<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>BrokenIRC: server_src/server_main.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">BrokenIRC
   &#160;<span id="projectnumber">0.0.42</span>
   </div>
   <div id="projectbrief">A &#39;not so functionnal&#39; irc server and a WIP client</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_20e5c1c74b8b955148e6b35ac4a0bc4d.html">server_src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">server_main.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="server_8h_source.html">../include/server.h</a>&quot;</code><br />
<code>#include &lt;unistd.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;sys/wait.h&gt;</code><br />
<code>#include &lt;arpa/inet.h&gt;</code><br />
<code>#include &lt;regex.h&gt;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for server_main.c:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c__incl.png" border="0" usemap="#server__src_2server__main_8c" alt=""/></div>
<map name="server__src_2server__main_8c" id="server__src_2server__main_8c">
<area shape="rect" id="node2" href="server_8h.html" title="../include/server.h" alt="" coords="150,80,277,107"/>
</map>
</div>
</div>
<p><a href="server__main_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a01aa22f887842d97133af9b3f2cf4a7c"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="server__main_8c.html#a01aa22f887842d97133af9b3f2cf4a7c">initco</a> (<a class="el" href="structt__serv.html">t_serv</a> *all, char **args, int *connected)</td></tr>
<tr class="separator:a01aa22f887842d97133af9b3f2cf4a7c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4178685c6a99dba7611faf9fe58f1a54"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="server__main_8c.html#a4178685c6a99dba7611faf9fe58f1a54">evhandler</a> (<a class="el" href="structt__serv.html">t_serv</a> *all, int newfd)</td></tr>
<tr class="separator:a4178685c6a99dba7611faf9fe58f1a54"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a825c9cedc1751b000c44487b4233c37c"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="server__main_8c.html#a825c9cedc1751b000c44487b4233c37c">getactiveclients</a> (<a class="el" href="structt__serv.html">t_serv</a> *all, char **args)</td></tr>
<tr class="separator:a825c9cedc1751b000c44487b4233c37c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af3e041546aaed3cd242c2b0e77162b39"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="server__main_8c.html#af3e041546aaed3cd242c2b0e77162b39">server</a> (char **args)</td></tr>
<tr class="separator:af3e041546aaed3cd242c2b0e77162b39"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0c99d968a34e803d378692bde2e3f18f"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="server__main_8c.html#a0c99d968a34e803d378692bde2e3f18f">main</a> (int ac, char **av)</td></tr>
<tr class="separator:a0c99d968a34e803d378692bde2e3f18f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="a4178685c6a99dba7611faf9fe58f1a54"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4178685c6a99dba7611faf9fe58f1a54">&#9670;&nbsp;</a></span>evhandler()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int evhandler </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structt__serv.html">t_serv</a> *&#160;</td>
          <td class="paramname"><em>all</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>newfd</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Main get commands / parse and exec runner function </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">all</td><td>the infamous structure </td></tr>
    <tr><td class="paramname">newfd</td><td>the client socket fd </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="server__main_8c_source.html#l00043">43</a> of file <a class="el" href="server__main_8c_source.html">server_main.c</a>.</p>

<p class="reference">References <a class="el" href="server_8h_source.html#l00091">t_serv::buf</a>, <a class="el" href="commands__parsing_8c_source.html#l00073">get_methods()</a>, <a class="el" href="server_8h_source.html#l00092">t_serv::host</a>, <a class="el" href="logs__helpers_8c_source.html#l00059">logthisevent()</a>, <a class="el" href="server_8h_source.html#l00090">t_serv::nread</a>, and <a class="el" href="server_8h_source.html#l00093">t_serv::service</a>.</p>

<p class="reference">Referenced by <a class="el" href="server__main_8c_source.html#l00074">getactiveclients()</a>.</p>
<div class="fragment"><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;{</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;        <span class="keyword">struct </span>sockaddr_in addr;</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;        socklen_t addr_size = <span class="keyword">sizeof</span>(<span class="keyword">struct </span>sockaddr_in);</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;        <span class="keywordtype">int</span> res = getpeername(newfd, (<span class="keyword">struct</span> sockaddr *)&amp;addr, &amp;addr_size);</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        <span class="keywordflow">if</span> (res == -1) {</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;                perror(<span class="stringliteral">&quot;evhandler: getpeername&quot;</span>);</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;        } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;                sprintf(all-&gt;<a class="code" href="structt__serv.html#a0dd3a9c2648da4fba88a38276803037c">host</a>, <span class="stringliteral">&quot;%s&quot;</span>, inet_ntoa(addr.sin_addr));</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;                sprintf(all-&gt;<a class="code" href="structt__serv.html#aee509c3823199bf9f0ad285a718260bd">service</a>, <span class="stringliteral">&quot;%d&quot;</span>, ntohs(addr.sin_port));</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;                <span class="keywordflow">if</span> (all-&gt;<a class="code" href="structt__serv.html#a85e55e3fe1bfb973e7f5d15a0a436b18">nread</a> &amp;&amp; <a class="code" href="logs__helpers_8c.html#a7e2903ce4461ed71cf294dd675bd4c49">logthisevent</a>(<span class="charliteral">&#39;c&#39;</span>, all)) {</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;                        <a class="code" href="commands__parsing_8c.html#ac5949d17278df5e1ada98dca25ccd961">get_methods</a>(all-&gt;<a class="code" href="structt__serv.html#a005714cf56aaffce970916774cf2b04a">buf</a>, newfd);</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;                } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;                        <a class="code" href="logs__helpers_8c.html#a7e2903ce4461ed71cf294dd675bd4c49">logthisevent</a>(<span class="charliteral">&#39;d&#39;</span>, all);</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;                }</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;        }</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;        <span class="keywordflow">return</span> (0);</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;}</div><div class="ttc" id="structt__serv_html_a005714cf56aaffce970916774cf2b04a"><div class="ttname"><a href="structt__serv.html#a005714cf56aaffce970916774cf2b04a">t_serv::buf</a></div><div class="ttdeci">char buf[BUF_SIZE]</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00091">server.h:91</a></div></div>
<div class="ttc" id="structt__serv_html_a0dd3a9c2648da4fba88a38276803037c"><div class="ttname"><a href="structt__serv.html#a0dd3a9c2648da4fba88a38276803037c">t_serv::host</a></div><div class="ttdeci">char host[NI_MAXHOST]</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00092">server.h:92</a></div></div>
<div class="ttc" id="logs__helpers_8c_html_a7e2903ce4461ed71cf294dd675bd4c49"><div class="ttname"><a href="logs__helpers_8c.html#a7e2903ce4461ed71cf294dd675bd4c49">logthisevent</a></div><div class="ttdeci">int logthisevent(const char etype, t_serv *all)</div><div class="ttdef"><b>Definition:</b> <a href="logs__helpers_8c_source.html#l00059">logs_helpers.c:59</a></div></div>
<div class="ttc" id="commands__parsing_8c_html_ac5949d17278df5e1ada98dca25ccd961"><div class="ttname"><a href="commands__parsing_8c.html#ac5949d17278df5e1ada98dca25ccd961">get_methods</a></div><div class="ttdeci">int get_methods(char *req, int clifd)</div><div class="ttdef"><b>Definition:</b> <a href="commands__parsing_8c_source.html#l00073">commands_parsing.c:73</a></div></div>
<div class="ttc" id="structt__serv_html_a85e55e3fe1bfb973e7f5d15a0a436b18"><div class="ttname"><a href="structt__serv.html#a85e55e3fe1bfb973e7f5d15a0a436b18">t_serv::nread</a></div><div class="ttdeci">ssize_t nread</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00090">server.h:90</a></div></div>
<div class="ttc" id="structt__serv_html_aee509c3823199bf9f0ad285a718260bd"><div class="ttname"><a href="structt__serv.html#aee509c3823199bf9f0ad285a718260bd">t_serv::service</a></div><div class="ttdeci">char service[NI_MAXSERV]</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00093">server.h:93</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c_a4178685c6a99dba7611faf9fe58f1a54_cgraph.png" border="0" usemap="#server__main_8c_a4178685c6a99dba7611faf9fe58f1a54_cgraph" alt=""/></div>
<map name="server__main_8c_a4178685c6a99dba7611faf9fe58f1a54_cgraph" id="server__main_8c_a4178685c6a99dba7611faf9fe58f1a54_cgraph">
<area shape="rect" id="node2" href="commands__parsing_8c.html#ac5949d17278df5e1ada98dca25ccd961" title="get_methods" alt="" coords="132,132,229,159"/>
<area shape="rect" id="node11" href="logs__helpers_8c.html#a7e2903ce4461ed71cf294dd675bd4c49" title="logthisevent" alt="" coords="135,208,227,235"/>
<area shape="rect" id="node3" href="commands__parsing_8c.html#a9bf380b201748032988ca121dc4ed068" title="free_buffers" alt="" coords="305,5,395,32"/>
<area shape="rect" id="node4" href="commands__parsing_8c.html#ad7cc037b9642ffd85e521546772eceae" title="get_args" alt="" coords="314,56,386,83"/>
<area shape="rect" id="node5" href="commands__parsing_8c.html#ae88af3c7c8c827d710efa585d851a414" title="get_commands" alt="" coords="295,107,405,133"/>
<area shape="rect" id="node6" href="channel__list_8c.html#a1c3fc93845d179d198452e745f3460b1" title="init_default_channel" alt="" coords="281,157,419,184"/>
<area shape="rect" id="node9" href="logs__helpers_8c.html#a805324e4c542079956ff84a290274d23" title="print_users_in_chans" alt="" coords="277,208,423,235"/>
<area shape="rect" id="node7" href="user__list_8c.html#ace045c243817cc0c9885bdf3b41263c0" title="get_new_user" alt="" coords="479,107,582,133"/>
<area shape="rect" id="node8" href="user__list_8c.html#a1cf3d818bc2607cb0f69c043dba3c039" title="get_new_userlist" alt="" coords="471,157,591,184"/>
<area shape="rect" id="node10" href="logs__helpers_8c.html#a45c9c768c2486ac046ac242d3c46aadb" title="print_users" alt="" coords="487,208,574,235"/>
<area shape="rect" id="node12" href="logs__helpers_8c.html#a2bcab2bec250f4df132d9cfc8fa070f0" title="get_host_string" alt="" coords="295,259,405,285"/>
</map>
</div>
<div class="dynheader">
Here is the caller graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c_a4178685c6a99dba7611faf9fe58f1a54_icgraph.png" border="0" usemap="#server__main_8c_a4178685c6a99dba7611faf9fe58f1a54_icgraph" alt=""/></div>
<map name="server__main_8c_a4178685c6a99dba7611faf9fe58f1a54_icgraph" id="server__main_8c_a4178685c6a99dba7611faf9fe58f1a54_icgraph">
<area shape="rect" id="node2" href="server__main_8c.html#a825c9cedc1751b000c44487b4233c37c" title="getactiveclients" alt="" coords="132,5,245,32"/>
<area shape="rect" id="node3" href="server__main_8c.html#af3e041546aaed3cd242c2b0e77162b39" title="server" alt="" coords="293,5,352,32"/>
<area shape="rect" id="node4" href="server__main_8c.html#a0c99d968a34e803d378692bde2e3f18f" title="main" alt="" coords="400,5,451,32"/>
</map>
</div>

</div>
</div>
<a id="a825c9cedc1751b000c44487b4233c37c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a825c9cedc1751b000c44487b4233c37c">&#9670;&nbsp;</a></span>getactiveclients()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int getactiveclients </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structt__serv.html">t_serv</a> *&#160;</td>
          <td class="paramname"><em>all</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char **&#160;</td>
          <td class="paramname"><em>args</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Get the active fd from event queue, if it's our server fd, <a class="el" href="server__main_8c.html#a01aa22f887842d97133af9b3f2cf4a7c">initco()</a> with the new connected client, else handle received cmd buffer through <a class="el" href="server__main_8c.html#a4178685c6a99dba7611faf9fe58f1a54">evhandler()</a> </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">all</td><td>the 'catch them all' structure with server infos </td></tr>
    <tr><td class="paramname">args</td><td>the argv pointer form main containing initial process names </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 fo normal exit (0) if a client / child process disconnect </dd></dl>
<dl class="section note"><dt>Note</dt><dd>must implement circular buffer instead of 2d char array see <a href="https://bit.ly/2s86kKz">this ref</a> for explanations and code snippets (note of note : will do it (maybe) later) </dd></dl>

<p class="definition">Definition at line <a class="el" href="server__main_8c_source.html#l00074">74</a> of file <a class="el" href="server__main_8c_source.html">server_main.c</a>.</p>

<p class="reference">References <a class="el" href="server_8h_source.html#l00091">t_serv::buf</a>, <a class="el" href="server_8h_source.html#l00024">BUF_SIZE</a>, <a class="el" href="server_8h_source.html#l00098">t_serv::events</a>, <a class="el" href="server__main_8c_source.html#l00043">evhandler()</a>, <a class="el" href="server__main_8c_source.html#l00020">initco()</a>, <a class="el" href="server_8h_source.html#l00089">t_serv::listen_sock</a>, <a class="el" href="server_8h_source.html#l00086">t_serv::nfds</a>, and <a class="el" href="server_8h_source.html#l00090">t_serv::nread</a>.</p>

<p class="reference">Referenced by <a class="el" href="server__main_8c_source.html#l00096">server()</a>.</p>
<div class="fragment"><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;{</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;        <span class="keywordtype">int</span> clifd = -1;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        <span class="keyword">static</span> <span class="keywordtype">int</span> connected;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n = 0; n &lt; all-&gt;<a class="code" href="structt__serv.html#a7659da4b3744e6ddd8f77f37d2138914">nfds</a>; ++n) {</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;                clifd = all-&gt;<a class="code" href="structt__serv.html#a3c6f3b16eed7e8c35eb4d2831583ea15">events</a>[n].data.fd;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;                <span class="keywordflow">if</span> (clifd == all-&gt;<a class="code" href="structt__serv.html#ac9f24d41d8822f2c1b7df4362e18cad9">listen_sock</a>) {</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;                        <a class="code" href="server__main_8c.html#a01aa22f887842d97133af9b3f2cf4a7c">initco</a>(all, args, &amp;connected);</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;                } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;                        memset(all-&gt;<a class="code" href="structt__serv.html#a005714cf56aaffce970916774cf2b04a">buf</a>, 0, <a class="code" href="server_8h.html#a6821bafc3c88dfb2e433a095df9940c6">BUF_SIZE</a>);</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;                        all-&gt;<a class="code" href="structt__serv.html#a85e55e3fe1bfb973e7f5d15a0a436b18">nread</a> = read(clifd, all-&gt;<a class="code" href="structt__serv.html#a005714cf56aaffce970916774cf2b04a">buf</a>, <a class="code" href="server_8h.html#a6821bafc3c88dfb2e433a095df9940c6">BUF_SIZE</a>);</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;                        <a class="code" href="server__main_8c.html#a4178685c6a99dba7611faf9fe58f1a54">evhandler</a>(all, clifd);</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;                        memset(all-&gt;<a class="code" href="structt__serv.html#a005714cf56aaffce970916774cf2b04a">buf</a>, 0, <a class="code" href="server_8h.html#a6821bafc3c88dfb2e433a095df9940c6">BUF_SIZE</a>);</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;                }</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;        }</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;        <span class="keywordflow">return</span> (0);</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;}</div><div class="ttc" id="server__main_8c_html_a01aa22f887842d97133af9b3f2cf4a7c"><div class="ttname"><a href="server__main_8c.html#a01aa22f887842d97133af9b3f2cf4a7c">initco</a></div><div class="ttdeci">static int initco(t_serv *all, char **args, int *connected)</div><div class="ttdef"><b>Definition:</b> <a href="server__main_8c_source.html#l00020">server_main.c:20</a></div></div>
<div class="ttc" id="structt__serv_html_a005714cf56aaffce970916774cf2b04a"><div class="ttname"><a href="structt__serv.html#a005714cf56aaffce970916774cf2b04a">t_serv::buf</a></div><div class="ttdeci">char buf[BUF_SIZE]</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00091">server.h:91</a></div></div>
<div class="ttc" id="structt__serv_html_a3c6f3b16eed7e8c35eb4d2831583ea15"><div class="ttname"><a href="structt__serv.html#a3c6f3b16eed7e8c35eb4d2831583ea15">t_serv::events</a></div><div class="ttdeci">struct epoll_event events[MAX_EVENTS]</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00098">server.h:98</a></div></div>
<div class="ttc" id="structt__serv_html_ac9f24d41d8822f2c1b7df4362e18cad9"><div class="ttname"><a href="structt__serv.html#ac9f24d41d8822f2c1b7df4362e18cad9">t_serv::listen_sock</a></div><div class="ttdeci">int listen_sock</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00089">server.h:89</a></div></div>
<div class="ttc" id="structt__serv_html_a85e55e3fe1bfb973e7f5d15a0a436b18"><div class="ttname"><a href="structt__serv.html#a85e55e3fe1bfb973e7f5d15a0a436b18">t_serv::nread</a></div><div class="ttdeci">ssize_t nread</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00090">server.h:90</a></div></div>
<div class="ttc" id="server_8h_html_a6821bafc3c88dfb2e433a095df9940c6"><div class="ttname"><a href="server_8h.html#a6821bafc3c88dfb2e433a095df9940c6">BUF_SIZE</a></div><div class="ttdeci">#define BUF_SIZE</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00024">server.h:24</a></div></div>
<div class="ttc" id="server__main_8c_html_a4178685c6a99dba7611faf9fe58f1a54"><div class="ttname"><a href="server__main_8c.html#a4178685c6a99dba7611faf9fe58f1a54">evhandler</a></div><div class="ttdeci">static int evhandler(t_serv *all, int newfd)</div><div class="ttdef"><b>Definition:</b> <a href="server__main_8c_source.html#l00043">server_main.c:43</a></div></div>
<div class="ttc" id="structt__serv_html_a7659da4b3744e6ddd8f77f37d2138914"><div class="ttname"><a href="structt__serv.html#a7659da4b3744e6ddd8f77f37d2138914">t_serv::nfds</a></div><div class="ttdeci">int nfds</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00086">server.h:86</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c_a825c9cedc1751b000c44487b4233c37c_cgraph.png" border="0" usemap="#server__main_8c_a825c9cedc1751b000c44487b4233c37c_cgraph" alt=""/></div>
<map name="server__main_8c_a825c9cedc1751b000c44487b4233c37c_cgraph" id="server__main_8c_a825c9cedc1751b000c44487b4233c37c_cgraph">
<area shape="rect" id="node2" href="server__main_8c.html#a4178685c6a99dba7611faf9fe58f1a54" title="evhandler" alt="" coords="167,208,245,235"/>
<area shape="rect" id="node14" href="server__main_8c.html#a01aa22f887842d97133af9b3f2cf4a7c" title="initco" alt="" coords="179,259,233,285"/>
<area shape="rect" id="node3" href="commands__parsing_8c.html#ac5949d17278df5e1ada98dca25ccd961" title="get_methods" alt="" coords="293,132,391,159"/>
<area shape="rect" id="node12" href="logs__helpers_8c.html#a7e2903ce4461ed71cf294dd675bd4c49" title="logthisevent" alt="" coords="296,208,388,235"/>
<area shape="rect" id="node4" href="commands__parsing_8c.html#a9bf380b201748032988ca121dc4ed068" title="free_buffers" alt="" coords="466,5,557,32"/>
<area shape="rect" id="node5" href="commands__parsing_8c.html#ad7cc037b9642ffd85e521546772eceae" title="get_args" alt="" coords="475,56,547,83"/>
<area shape="rect" id="node6" href="commands__parsing_8c.html#ae88af3c7c8c827d710efa585d851a414" title="get_commands" alt="" coords="456,107,567,133"/>
<area shape="rect" id="node7" href="channel__list_8c.html#a1c3fc93845d179d198452e745f3460b1" title="init_default_channel" alt="" coords="443,157,580,184"/>
<area shape="rect" id="node10" href="logs__helpers_8c.html#a805324e4c542079956ff84a290274d23" title="print_users_in_chans" alt="" coords="439,208,584,235"/>
<area shape="rect" id="node8" href="user__list_8c.html#ace045c243817cc0c9885bdf3b41263c0" title="get_new_user" alt="" coords="641,107,743,133"/>
<area shape="rect" id="node9" href="user__list_8c.html#a1cf3d818bc2607cb0f69c043dba3c039" title="get_new_userlist" alt="" coords="632,157,752,184"/>
<area shape="rect" id="node11" href="logs__helpers_8c.html#a45c9c768c2486ac046ac242d3c46aadb" title="print_users" alt="" coords="649,208,735,235"/>
<area shape="rect" id="node13" href="logs__helpers_8c.html#a2bcab2bec250f4df132d9cfc8fa070f0" title="get_host_string" alt="" coords="456,259,567,285"/>
<area shape="rect" id="node15" href="server__init_8c.html#aa9bc3ff8e7f409540f85b3cc97636500" title="set_clifd" alt="" coords="307,259,377,285"/>
</map>
</div>
<div class="dynheader">
Here is the caller graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c_a825c9cedc1751b000c44487b4233c37c_icgraph.png" border="0" usemap="#server__main_8c_a825c9cedc1751b000c44487b4233c37c_icgraph" alt=""/></div>
<map name="server__main_8c_a825c9cedc1751b000c44487b4233c37c_icgraph" id="server__main_8c_a825c9cedc1751b000c44487b4233c37c_icgraph">
<area shape="rect" id="node2" href="server__main_8c.html#af3e041546aaed3cd242c2b0e77162b39" title="server" alt="" coords="167,5,225,32"/>
<area shape="rect" id="node3" href="server__main_8c.html#a0c99d968a34e803d378692bde2e3f18f" title="main" alt="" coords="273,5,324,32"/>
</map>
</div>

</div>
</div>
<a id="a01aa22f887842d97133af9b3f2cf4a7c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a01aa22f887842d97133af9b3f2cf4a7c">&#9670;&nbsp;</a></span>initco()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int initco </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structt__serv.html">t_serv</a> *&#160;</td>
          <td class="paramname"><em>all</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char **&#160;</td>
          <td class="paramname"><em>args</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>connected</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Set the new accept() client socket in epoll event list for new client handling if connection succeed </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">all</td><td>the 'foure tout' server struct </td></tr>
    <tr><td class="paramname">args</td><td>the argv from main to update child process name </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="server__main_8c_source.html#l00020">20</a> of file <a class="el" href="server__main_8c_source.html">server_main.c</a>.</p>

<p class="reference">References <a class="el" href="server_8h_source.html#l00088">t_serv::conn_sock</a>, <a class="el" href="server_8h_source.html#l00087">t_serv::epollfd</a>, <a class="el" href="server_8h_source.html#l00097">t_serv::ev</a>, <a class="el" href="server_8h_source.html#l00089">t_serv::listen_sock</a>, and <a class="el" href="server__init_8c_source.html#l00018">set_clifd()</a>.</p>

<p class="reference">Referenced by <a class="el" href="server__main_8c_source.html#l00074">getactiveclients()</a>.</p>
<div class="fragment"><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;{</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;        <span class="keywordtype">int</span> rt = 84;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;        <span class="keyword">struct </span>sockaddr_in addr;</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;        socklen_t addr_size = <span class="keyword">sizeof</span>(<span class="keyword">struct </span>sockaddr_in);</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;        <span class="keyword">struct </span>sockaddr *cliaddr = (<span class="keyword">struct </span>sockaddr *)&amp;addr;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;        <span class="keywordtype">char</span> *okco = <span class="stringliteral">&quot;Someone connect to me!\n&quot;</span>;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;        all-&gt;<a class="code" href="structt__serv.html#a5c3a4553e608f252da1d211b20b459ec">conn_sock</a> = accept(all-&gt;<a class="code" href="structt__serv.html#ac9f24d41d8822f2c1b7df4362e18cad9">listen_sock</a>, cliaddr, &amp;addr_size);</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        <span class="keywordflow">if</span> (all-&gt;<a class="code" href="structt__serv.html#a5c3a4553e608f252da1d211b20b459ec">conn_sock</a> == -1) {</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;                perror(<span class="stringliteral">&quot;initco: accept&quot;</span>);</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;        } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!(rt = <a class="code" href="server__init_8c.html#aa9bc3ff8e7f409540f85b3cc97636500">set_clifd</a>(all-&gt;<a class="code" href="structt__serv.html#a5c3a4553e608f252da1d211b20b459ec">conn_sock</a>, all-&gt;<a class="code" href="structt__serv.html#a46bee037324e9deec26f15fbc4f6d8e5">epollfd</a>, &amp;all-&gt;<a class="code" href="structt__serv.html#aa95442079d9e7a2294ad8df1335ae0f4">ev</a>))) {</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;                fprintf(stdout, <span class="stringliteral">&quot;\n%s: %s\n&quot;</span>, args[0], okco);</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;                *(connected) += 1;</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;        }</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;        <span class="keywordflow">return</span> (rt);</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;}</div><div class="ttc" id="structt__serv_html_a5c3a4553e608f252da1d211b20b459ec"><div class="ttname"><a href="structt__serv.html#a5c3a4553e608f252da1d211b20b459ec">t_serv::conn_sock</a></div><div class="ttdeci">int conn_sock</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00088">server.h:88</a></div></div>
<div class="ttc" id="structt__serv_html_ac9f24d41d8822f2c1b7df4362e18cad9"><div class="ttname"><a href="structt__serv.html#ac9f24d41d8822f2c1b7df4362e18cad9">t_serv::listen_sock</a></div><div class="ttdeci">int listen_sock</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00089">server.h:89</a></div></div>
<div class="ttc" id="structt__serv_html_a46bee037324e9deec26f15fbc4f6d8e5"><div class="ttname"><a href="structt__serv.html#a46bee037324e9deec26f15fbc4f6d8e5">t_serv::epollfd</a></div><div class="ttdeci">int epollfd</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00087">server.h:87</a></div></div>
<div class="ttc" id="server__init_8c_html_aa9bc3ff8e7f409540f85b3cc97636500"><div class="ttname"><a href="server__init_8c.html#aa9bc3ff8e7f409540f85b3cc97636500">set_clifd</a></div><div class="ttdeci">int set_clifd(int clisock, int epollfd, struct epoll_event *ev)</div><div class="ttdef"><b>Definition:</b> <a href="server__init_8c_source.html#l00018">server_init.c:18</a></div></div>
<div class="ttc" id="structt__serv_html_aa95442079d9e7a2294ad8df1335ae0f4"><div class="ttname"><a href="structt__serv.html#aa95442079d9e7a2294ad8df1335ae0f4">t_serv::ev</a></div><div class="ttdeci">struct epoll_event ev</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00097">server.h:97</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c_a01aa22f887842d97133af9b3f2cf4a7c_cgraph.png" border="0" usemap="#server__main_8c_a01aa22f887842d97133af9b3f2cf4a7c_cgraph" alt=""/></div>
<map name="server__main_8c_a01aa22f887842d97133af9b3f2cf4a7c_cgraph" id="server__main_8c_a01aa22f887842d97133af9b3f2cf4a7c_cgraph">
<area shape="rect" id="node2" href="server__init_8c.html#aa9bc3ff8e7f409540f85b3cc97636500" title="set_clifd" alt="" coords="107,5,177,32"/>
</map>
</div>
<div class="dynheader">
Here is the caller graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c_a01aa22f887842d97133af9b3f2cf4a7c_icgraph.png" border="0" usemap="#server__main_8c_a01aa22f887842d97133af9b3f2cf4a7c_icgraph" alt=""/></div>
<map name="server__main_8c_a01aa22f887842d97133af9b3f2cf4a7c_icgraph" id="server__main_8c_a01aa22f887842d97133af9b3f2cf4a7c_icgraph">
<area shape="rect" id="node2" href="server__main_8c.html#a825c9cedc1751b000c44487b4233c37c" title="getactiveclients" alt="" coords="107,5,220,32"/>
<area shape="rect" id="node3" href="server__main_8c.html#af3e041546aaed3cd242c2b0e77162b39" title="server" alt="" coords="268,5,327,32"/>
<area shape="rect" id="node4" href="server__main_8c.html#a0c99d968a34e803d378692bde2e3f18f" title="main" alt="" coords="375,5,425,32"/>
</map>
</div>

</div>
</div>
<a id="a0c99d968a34e803d378692bde2e3f18f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0c99d968a34e803d378692bde2e3f18f">&#9670;&nbsp;</a></span>main()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ac</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char **&#160;</td>
          <td class="paramname"><em>av</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Self explanatory (here is the <a class="el" href="server__main_8c.html#a0c99d968a34e803d378692bde2e3f18f">main()</a>) </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ac</td><td>the number of received args </td></tr>
    <tr><td class="paramname">av</td><td>the received args, av[1] must be the server port </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="server__main_8c_source.html#l00124">124</a> of file <a class="el" href="server__main_8c_source.html">server_main.c</a>.</p>

<p class="reference">References <a class="el" href="server__main_8c_source.html#l00096">server()</a>, and <a class="el" href="sig__handler_8c_source.html#l00015">sig_handler()</a>.</p>
<div class="fragment"><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;{</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;        <span class="keywordtype">int</span> rt = 0;</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;        <span class="keywordtype">char</span> *endptr = NULL;</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;        <span class="keywordtype">char</span> *port = NULL;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;        <span class="keywordtype">int</span> val = 0;</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;        <span class="keywordflow">if</span> (ac == 2) {</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;                port = av[1];</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;                val = strtol(port, &amp;endptr, 10);</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;                signal(SIGINT, <a class="code" href="sig__handler_8c.html#a4f31a6fd48ee5d4579ae4aaaa3cae285">sig_handler</a>);</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;                <span class="keywordflow">if</span> (endptr != port  &amp;&amp; val &gt;= 1024)</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;                        rt = <a class="code" href="server__main_8c.html#af3e041546aaed3cd242c2b0e77162b39">server</a>(av);</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;                <span class="keywordflow">else</span></div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;                        rt = 84;</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;        } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;                fprintf(stderr, <span class="stringliteral">&quot;%s: [port]\n&quot;</span>, av[0]);</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;                rt = 84;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;        }</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;        <span class="keywordflow">return</span> (rt);</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;}</div><div class="ttc" id="server__main_8c_html_af3e041546aaed3cd242c2b0e77162b39"><div class="ttname"><a href="server__main_8c.html#af3e041546aaed3cd242c2b0e77162b39">server</a></div><div class="ttdeci">int server(char **args)</div><div class="ttdef"><b>Definition:</b> <a href="server__main_8c_source.html#l00096">server_main.c:96</a></div></div>
<div class="ttc" id="sig__handler_8c_html_a4f31a6fd48ee5d4579ae4aaaa3cae285"><div class="ttname"><a href="sig__handler_8c.html#a4f31a6fd48ee5d4579ae4aaaa3cae285">sig_handler</a></div><div class="ttdeci">void sig_handler(int signo)</div><div class="ttdef"><b>Definition:</b> <a href="sig__handler_8c_source.html#l00015">sig_handler.c:15</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c_a0c99d968a34e803d378692bde2e3f18f_cgraph.png" border="0" usemap="#server__main_8c_a0c99d968a34e803d378692bde2e3f18f_cgraph" alt=""/></div>
<map name="server__main_8c_a0c99d968a34e803d378692bde2e3f18f_cgraph" id="server__main_8c_a0c99d968a34e803d378692bde2e3f18f_cgraph">
<area shape="rect" id="node2" href="server__main_8c.html#af3e041546aaed3cd242c2b0e77162b39" title="server" alt="" coords="119,157,177,184"/>
<area shape="rect" id="node22" href="sig__handler_8c.html#a4f31a6fd48ee5d4579ae4aaaa3cae285" title="sig_handler" alt="" coords="104,208,192,235"/>
<area shape="rect" id="node3" href="server__init_8c.html#a3802a71fa34e93cb1d85f919914f5abf" title="set_iface" alt="" coords="259,81,334,108"/>
<area shape="rect" id="node4" href="server__init_8c.html#a1f61d16ccfab82b21ca40ce23feb7c02" title="set_sockfd" alt="" coords="253,132,340,159"/>
<area shape="rect" id="node6" href="server__init_8c.html#a5cb15d408ef32c09c2485937503438ed" title="set_epoll" alt="" coords="259,183,334,209"/>
<area shape="rect" id="node7" href="server__main_8c.html#a825c9cedc1751b000c44487b4233c37c" title="getactiveclients" alt="" coords="240,233,353,260"/>
<area shape="rect" id="node5" href="server__init_8c.html#a381b88f843ed1ebdaa5b2a8ded74931b" title="prevent_reused" alt="" coords="401,132,512,159"/>
<area shape="rect" id="node8" href="server__main_8c.html#a4178685c6a99dba7611faf9fe58f1a54" title="evhandler" alt="" coords="417,208,496,235"/>
<area shape="rect" id="node20" href="server__main_8c.html#a01aa22f887842d97133af9b3f2cf4a7c" title="initco" alt="" coords="430,259,483,285"/>
<area shape="rect" id="node9" href="commands__parsing_8c.html#ac5949d17278df5e1ada98dca25ccd961" title="get_methods" alt="" coords="560,132,657,159"/>
<area shape="rect" id="node18" href="logs__helpers_8c.html#a7e2903ce4461ed71cf294dd675bd4c49" title="logthisevent" alt="" coords="563,208,655,235"/>
<area shape="rect" id="node10" href="commands__parsing_8c.html#a9bf380b201748032988ca121dc4ed068" title="free_buffers" alt="" coords="733,5,823,32"/>
<area shape="rect" id="node11" href="commands__parsing_8c.html#ad7cc037b9642ffd85e521546772eceae" title="get_args" alt="" coords="742,56,814,83"/>
<area shape="rect" id="node12" href="commands__parsing_8c.html#ae88af3c7c8c827d710efa585d851a414" title="get_commands" alt="" coords="723,107,833,133"/>
<area shape="rect" id="node13" href="channel__list_8c.html#a1c3fc93845d179d198452e745f3460b1" title="init_default_channel" alt="" coords="709,157,847,184"/>
<area shape="rect" id="node16" href="logs__helpers_8c.html#a805324e4c542079956ff84a290274d23" title="print_users_in_chans" alt="" coords="705,208,851,235"/>
<area shape="rect" id="node14" href="user__list_8c.html#ace045c243817cc0c9885bdf3b41263c0" title="get_new_user" alt="" coords="907,107,1010,133"/>
<area shape="rect" id="node15" href="user__list_8c.html#a1cf3d818bc2607cb0f69c043dba3c039" title="get_new_userlist" alt="" coords="899,157,1019,184"/>
<area shape="rect" id="node17" href="logs__helpers_8c.html#a45c9c768c2486ac046ac242d3c46aadb" title="print_users" alt="" coords="915,208,1002,235"/>
<area shape="rect" id="node19" href="logs__helpers_8c.html#a2bcab2bec250f4df132d9cfc8fa070f0" title="get_host_string" alt="" coords="723,259,833,285"/>
<area shape="rect" id="node21" href="server__init_8c.html#aa9bc3ff8e7f409540f85b3cc97636500" title="set_clifd" alt="" coords="573,259,644,285"/>
</map>
</div>

</div>
</div>
<a id="af3e041546aaed3cd242c2b0e77162b39"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af3e041546aaed3cd242c2b0e77162b39">&#9670;&nbsp;</a></span>server()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int server </td>
          <td>(</td>
          <td class="paramtype">char **&#160;</td>
          <td class="paramname"><em>args</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Contain the main 'listening for event' loop  read the various notes on documentation and do what requested </p>

<p class="definition">Definition at line <a class="el" href="server__main_8c_source.html#l00096">96</a> of file <a class="el" href="server__main_8c_source.html">server_main.c</a>.</p>

<p class="reference">References <a class="el" href="server_8h_source.html#l00087">t_serv::epollfd</a>, <a class="el" href="server_8h_source.html#l00098">t_serv::events</a>, <a class="el" href="server_8h_source.html#l00046">EVER</a>, <a class="el" href="server__main_8c_source.html#l00074">getactiveclients()</a>, <a class="el" href="server_8h_source.html#l00096">t_serv::hints</a>, <a class="el" href="server_8h_source.html#l00089">t_serv::listen_sock</a>, <a class="el" href="server_8h_source.html#l00027">MAX_EVENTS</a>, <a class="el" href="server_8h_source.html#l00086">t_serv::nfds</a>, <a class="el" href="server_8h_source.html#l00095">t_serv::res</a>, <a class="el" href="server__init_8c_source.html#l00059">set_epoll()</a>, <a class="el" href="server__init_8c_source.html#l00034">set_iface()</a>, and <a class="el" href="server__init_8c_source.html#l00100">set_sockfd()</a>.</p>

<p class="reference">Referenced by <a class="el" href="server__main_8c_source.html#l00124">main()</a>.</p>
<div class="fragment"><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;{</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="keywordtype">int</span> rt = 0;</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        <a class="code" href="structt__serv.html">t_serv</a> all;</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        <a class="code" href="server__init_8c.html#a3802a71fa34e93cb1d85f919914f5abf">set_iface</a>(&amp;all.<a class="code" href="structt__serv.html#a71d55fd97c2ffc84c72b17820396cdff">hints</a>, &amp;all.<a class="code" href="structt__serv.html#ae8783e38ef0c183366703267ca7b3298">res</a>, args[1]);</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        all.<a class="code" href="structt__serv.html#ac9f24d41d8822f2c1b7df4362e18cad9">listen_sock</a> = <a class="code" href="server__init_8c.html#a1f61d16ccfab82b21ca40ce23feb7c02">set_sockfd</a>(&amp;all);</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        <span class="keywordflow">if</span> (all.<a class="code" href="structt__serv.html#ac9f24d41d8822f2c1b7df4362e18cad9">listen_sock</a> &lt; 0 || <a class="code" href="server__init_8c.html#a5cb15d408ef32c09c2485937503438ed">set_epoll</a>(&amp;all) == -1) {</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;                rt = 84;</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;        } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;                <span class="keywordflow">for</span> (<a class="code" href="server_8h.html#a2b912ed39df233b43d7a093814705afb">EVER</a>) {</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;                        all.<a class="code" href="structt__serv.html#a7659da4b3744e6ddd8f77f37d2138914">nfds</a> = epoll_wait(all.<a class="code" href="structt__serv.html#a46bee037324e9deec26f15fbc4f6d8e5">epollfd</a>, all.<a class="code" href="structt__serv.html#a3c6f3b16eed7e8c35eb4d2831583ea15">events</a>,</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;                                <a class="code" href="server_8h.html#ae42954bb8545d24e3e9dcde5920c9a0b">MAX_EVENTS</a>, -1);</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;                        <span class="keywordflow">if</span> (all.<a class="code" href="structt__serv.html#a7659da4b3744e6ddd8f77f37d2138914">nfds</a> == -1) {</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;                                perror(<span class="stringliteral">&quot;server: epoll_wait&quot;</span>);</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;                                <span class="keywordflow">break</span>;</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;                        }</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;                        rt = <a class="code" href="server__main_8c.html#a825c9cedc1751b000c44487b4233c37c">getactiveclients</a>(&amp;all, args);</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;                }</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;                close(all.<a class="code" href="structt__serv.html#ac9f24d41d8822f2c1b7df4362e18cad9">listen_sock</a>);</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;        }</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;        <span class="keywordflow">return</span> (rt);</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;}</div><div class="ttc" id="structt__serv_html_a3c6f3b16eed7e8c35eb4d2831583ea15"><div class="ttname"><a href="structt__serv.html#a3c6f3b16eed7e8c35eb4d2831583ea15">t_serv::events</a></div><div class="ttdeci">struct epoll_event events[MAX_EVENTS]</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00098">server.h:98</a></div></div>
<div class="ttc" id="server__main_8c_html_a825c9cedc1751b000c44487b4233c37c"><div class="ttname"><a href="server__main_8c.html#a825c9cedc1751b000c44487b4233c37c">getactiveclients</a></div><div class="ttdeci">static int getactiveclients(t_serv *all, char **args)</div><div class="ttdef"><b>Definition:</b> <a href="server__main_8c_source.html#l00074">server_main.c:74</a></div></div>
<div class="ttc" id="structt__serv_html_ac9f24d41d8822f2c1b7df4362e18cad9"><div class="ttname"><a href="structt__serv.html#ac9f24d41d8822f2c1b7df4362e18cad9">t_serv::listen_sock</a></div><div class="ttdeci">int listen_sock</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00089">server.h:89</a></div></div>
<div class="ttc" id="structt__serv_html_a46bee037324e9deec26f15fbc4f6d8e5"><div class="ttname"><a href="structt__serv.html#a46bee037324e9deec26f15fbc4f6d8e5">t_serv::epollfd</a></div><div class="ttdeci">int epollfd</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00087">server.h:87</a></div></div>
<div class="ttc" id="server__init_8c_html_a5cb15d408ef32c09c2485937503438ed"><div class="ttname"><a href="server__init_8c.html#a5cb15d408ef32c09c2485937503438ed">set_epoll</a></div><div class="ttdeci">int set_epoll(t_serv *all)</div><div class="ttdef"><b>Definition:</b> <a href="server__init_8c_source.html#l00059">server_init.c:59</a></div></div>
<div class="ttc" id="structt__serv_html"><div class="ttname"><a href="structt__serv.html">t_serv</a></div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00085">server.h:85</a></div></div>
<div class="ttc" id="server_8h_html_ae42954bb8545d24e3e9dcde5920c9a0b"><div class="ttname"><a href="server_8h.html#ae42954bb8545d24e3e9dcde5920c9a0b">MAX_EVENTS</a></div><div class="ttdeci">#define MAX_EVENTS</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00027">server.h:27</a></div></div>
<div class="ttc" id="server_8h_html_a2b912ed39df233b43d7a093814705afb"><div class="ttname"><a href="server_8h.html#a2b912ed39df233b43d7a093814705afb">EVER</a></div><div class="ttdeci">#define EVER</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00046">server.h:46</a></div></div>
<div class="ttc" id="structt__serv_html_a71d55fd97c2ffc84c72b17820396cdff"><div class="ttname"><a href="structt__serv.html#a71d55fd97c2ffc84c72b17820396cdff">t_serv::hints</a></div><div class="ttdeci">adrinf hints</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00096">server.h:96</a></div></div>
<div class="ttc" id="server__init_8c_html_a1f61d16ccfab82b21ca40ce23feb7c02"><div class="ttname"><a href="server__init_8c.html#a1f61d16ccfab82b21ca40ce23feb7c02">set_sockfd</a></div><div class="ttdeci">int set_sockfd(t_serv *all)</div><div class="ttdef"><b>Definition:</b> <a href="server__init_8c_source.html#l00100">server_init.c:100</a></div></div>
<div class="ttc" id="structt__serv_html_ae8783e38ef0c183366703267ca7b3298"><div class="ttname"><a href="structt__serv.html#ae8783e38ef0c183366703267ca7b3298">t_serv::res</a></div><div class="ttdeci">adrinf * res</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00095">server.h:95</a></div></div>
<div class="ttc" id="server__init_8c_html_a3802a71fa34e93cb1d85f919914f5abf"><div class="ttname"><a href="server__init_8c.html#a3802a71fa34e93cb1d85f919914f5abf">set_iface</a></div><div class="ttdeci">int set_iface(adrinf *hints, adrinf **res, const char *port)</div><div class="ttdef"><b>Definition:</b> <a href="server__init_8c_source.html#l00034">server_init.c:34</a></div></div>
<div class="ttc" id="structt__serv_html_a7659da4b3744e6ddd8f77f37d2138914"><div class="ttname"><a href="structt__serv.html#a7659da4b3744e6ddd8f77f37d2138914">t_serv::nfds</a></div><div class="ttdeci">int nfds</div><div class="ttdef"><b>Definition:</b> <a href="server_8h_source.html#l00086">server.h:86</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c_af3e041546aaed3cd242c2b0e77162b39_cgraph.png" border="0" usemap="#server__main_8c_af3e041546aaed3cd242c2b0e77162b39_cgraph" alt=""/></div>
<map name="server__main_8c_af3e041546aaed3cd242c2b0e77162b39_cgraph" id="server__main_8c_af3e041546aaed3cd242c2b0e77162b39_cgraph">
<area shape="rect" id="node2" href="server__main_8c.html#a825c9cedc1751b000c44487b4233c37c" title="getactiveclients" alt="" coords="112,233,225,260"/>
<area shape="rect" id="node17" href="server__init_8c.html#a5cb15d408ef32c09c2485937503438ed" title="set_epoll" alt="" coords="131,284,206,311"/>
<area shape="rect" id="node18" href="server__init_8c.html#a3802a71fa34e93cb1d85f919914f5abf" title="set_iface" alt="" coords="131,335,206,361"/>
<area shape="rect" id="node19" href="server__init_8c.html#a1f61d16ccfab82b21ca40ce23feb7c02" title="set_sockfd" alt="" coords="125,385,212,412"/>
<area shape="rect" id="node3" href="server__main_8c.html#a4178685c6a99dba7611faf9fe58f1a54" title="evhandler" alt="" coords="289,208,368,235"/>
<area shape="rect" id="node15" href="server__main_8c.html#a01aa22f887842d97133af9b3f2cf4a7c" title="initco" alt="" coords="302,259,355,285"/>
<area shape="rect" id="node4" href="commands__parsing_8c.html#ac5949d17278df5e1ada98dca25ccd961" title="get_methods" alt="" coords="432,132,529,159"/>
<area shape="rect" id="node13" href="logs__helpers_8c.html#a7e2903ce4461ed71cf294dd675bd4c49" title="logthisevent" alt="" coords="435,208,527,235"/>
<area shape="rect" id="node5" href="commands__parsing_8c.html#a9bf380b201748032988ca121dc4ed068" title="free_buffers" alt="" coords="605,5,695,32"/>
<area shape="rect" id="node6" href="commands__parsing_8c.html#ad7cc037b9642ffd85e521546772eceae" title="get_args" alt="" coords="614,56,686,83"/>
<area shape="rect" id="node7" href="commands__parsing_8c.html#ae88af3c7c8c827d710efa585d851a414" title="get_commands" alt="" coords="595,107,705,133"/>
<area shape="rect" id="node8" href="channel__list_8c.html#a1c3fc93845d179d198452e745f3460b1" title="init_default_channel" alt="" coords="581,157,719,184"/>
<area shape="rect" id="node11" href="logs__helpers_8c.html#a805324e4c542079956ff84a290274d23" title="print_users_in_chans" alt="" coords="577,208,723,235"/>
<area shape="rect" id="node9" href="user__list_8c.html#ace045c243817cc0c9885bdf3b41263c0" title="get_new_user" alt="" coords="779,107,882,133"/>
<area shape="rect" id="node10" href="user__list_8c.html#a1cf3d818bc2607cb0f69c043dba3c039" title="get_new_userlist" alt="" coords="771,157,891,184"/>
<area shape="rect" id="node12" href="logs__helpers_8c.html#a45c9c768c2486ac046ac242d3c46aadb" title="print_users" alt="" coords="787,208,874,235"/>
<area shape="rect" id="node14" href="logs__helpers_8c.html#a2bcab2bec250f4df132d9cfc8fa070f0" title="get_host_string" alt="" coords="595,259,705,285"/>
<area shape="rect" id="node16" href="server__init_8c.html#aa9bc3ff8e7f409540f85b3cc97636500" title="set_clifd" alt="" coords="445,259,516,285"/>
<area shape="rect" id="node20" href="server__init_8c.html#a381b88f843ed1ebdaa5b2a8ded74931b" title="prevent_reused" alt="" coords="273,385,384,412"/>
</map>
</div>
<div class="dynheader">
Here is the caller graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="server__main_8c_af3e041546aaed3cd242c2b0e77162b39_icgraph.png" border="0" usemap="#server__main_8c_af3e041546aaed3cd242c2b0e77162b39_icgraph" alt=""/></div>
<map name="server__main_8c_af3e041546aaed3cd242c2b0e77162b39_icgraph" id="server__main_8c_af3e041546aaed3cd242c2b0e77162b39_icgraph">
<area shape="rect" id="node2" href="server__main_8c.html#a0c99d968a34e803d378692bde2e3f18f" title="main" alt="" coords="112,5,163,32"/>
</map>
</div>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
